﻿using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using ZX.HIS.IDAL;
using ZX.HIS.DBUtility;//Please add references
using ZX.HIS.Model;
using System.Collections.Generic;
namespace ZX.HIS.SQLServerDAL
{
    /// <summary>
    /// 数据访问类:DrupInfo
    /// </summary>
    public partial class DrupInfo : IDrupInfo
    {
        public DrupInfo()
        { }
        #region Depart自写方法

        /// <summary>
        /// 药品信息表的添加
        /// </summary>
        /// <param name="mode"></param>
        /// <returns></returns>
        public int DrupInfoAdd(ZX.HIS.Model.DrupInfo mode)
        {
            StringBuilder sql = new StringBuilder();
            sql.AppendLine("");
            sql.AppendLine("INSERT INTO tbDrupInfo");
            sql.AppendLine("(HospitalId,DrugTypeId, DrugName,DrugIsOtc,DrugPackSpece,OpenDoseName,DrugState,ProductId,DrugApprovalNo,DrugBarCode,DrugPurchasePrice)");
            sql.AppendLine("VALUES");
            sql.AppendLine("(@HospitalId,@DrugTypeId,@DrugName,@DrugIsOtc,@DrugPackSpece,@OpenDoseName,@DrugState,@ProductId,@DrugApprovalNo,@DrugBarCode,@DrugPurchasePrice)");
            SqlParameter[] paemeter ={
                                         new  SqlParameter("@HospitalId",SqlDbType.Int),//
                                         new  SqlParameter("@DrugTypeId",SqlDbType.VarChar),
                                         new  SqlParameter("@DrugName",SqlDbType.VarChar,500),
                                         new  SqlParameter("@DrugIsOtc",SqlDbType.Int),//
                                         new  SqlParameter("@DrugPackSpece",SqlDbType.VarChar,100),
                                         new  SqlParameter("@OpenDoseName",SqlDbType.VarChar),
                                         new  SqlParameter("@DrugState",SqlDbType.Int),//
                                         new  SqlParameter("@ProductId",SqlDbType.Int),
                                         new  SqlParameter("@DrugApprovalNo",SqlDbType.VarChar),
                                         new  SqlParameter("@DrugBarCode",SqlDbType.VarChar),
                                         new SqlParameter("@DrugPurchasePrice",SqlDbType.Decimal)
                        };
            paemeter[0].Value = mode.HospitalId;
            paemeter[1].Value = mode.DrugTypeId;
            paemeter[2].Value = mode.DrugName;
            paemeter[3].Value = mode.DrugIsOtc;
            paemeter[4].Value = mode.DrugPackSpece;
            paemeter[5].Value = mode.OpenDoseName;
            paemeter[6].Value = mode.DrugState;
            paemeter[7].Value = mode.ProductId;
            paemeter[8].Value = mode.DrugApprovalNo;
            paemeter[9].Value = mode.DrugBarCode;
            paemeter[10].Value = mode.DrugPurchasePrice;
            object obj = SqlDBhelper.ExecuteNonQuery(sql.ToString(), paemeter);
            if (obj != null)
            {
                return Convert.ToInt32(obj);
            }
            else
            {
                return 0;
            }
        }
        /// <summary>
        /// 药品显示的分页
        /// </summary>
        /// <param name="PageIndex"></param>
        /// <param name="PageSiez"></param>
        /// <returns></returns>
        public List<ZX.HIS.Model.DrupInfo> DrupInfoList(int PageIndex, int PageSiez, string DrugName, string DrugTypeId, int DrugState)
        {
            StringBuilder sql = new StringBuilder();
            sql.AppendLine("SELECT  * FROM (");
            sql.AppendLine("SELECT ROW_NUMBER() OVER(ORDER BY a.DrugId) R ,a.DrugId, a.DrugName ,a.DrugTypeId");
            sql.AppendLine(" ,D.ProductName,a.DrugPackSpece  ,B.DrugInvThrVal ,B.DrugInvPresPrice,C.DrugWareNumber FROM dbo.tbDrupInfo a ");
            sql.AppendLine(" LEFT JOIN  tbDrugInventory B ON A.DrugId=B.DrugId");
            sql.AppendLine("LEFT JOIN tbDrugWareHouse C ON A.DrugId=C.DrugId");
            sql.AppendLine("LEFT JOIN tbProduct D ON A.ProductId=D.ProductId");
            sql.AppendLine(" where 1=1");
            if (DrugName != "")
            {
                sql.AppendLine(" and DrugName like '%" + DrugName + "%'");
            }
            if (DrugTypeId != "")
            {
                sql.AppendLine(" and a.DrugTypeId = '" + DrugTypeId + "'");
            }
            if (DrugState != 0)
            {
                sql.AppendLine(" and DrugState = " + DrugState + "");
            }
            sql.AppendLine(" ) T WHERE");
            sql.AppendLine(" R BETWEEN " + ((PageIndex - 1) * PageSiez + 1) + "  AND  " + PageIndex * PageSiez + "");
            return SqlDBhelper.GetList<ZX.HIS.Model.DrupInfo>(sql.ToString());
        }
       /// <summary>
       /// 总条数
       /// </summary>
       /// <returns></returns>
        public int DrupInfoCount(string DrugName, string DrugTypeId, int DrugState)
        {
            StringBuilder sql = new StringBuilder();
            sql.AppendLine("SELECT COUNT(*) FROM tbDrupInfo ");
            sql.AppendLine(" where 1=1");
            if (DrugName != "")
            {
                sql.AppendLine(" and DrugName like '%" + DrugName + "%'");
            }
            if (DrugTypeId != "")
            {
                sql.AppendLine(" and DrugTypeId = '" + DrugTypeId + "'");
            }
            if (DrugState != 0)
            {
                sql.AppendLine(" and DrugState = " + DrugState + "");
            }
            return SqlDBhelper.ExecuteScalarInt(sql.ToString());
        }
        /// <summary>
        /// 显示药品信息表
        /// </summary>
        /// <returns></returns>
        public List<ZX.HIS.Model.DrupInfo> DrupInfoList()
        {
            StringBuilder SQL = new StringBuilder();
            SQL.AppendLine("  SELECT tbDrupInfo.DrugId,tbDrupInfo.HospitalId,tbDrupInfo.DrugTypeId,tbDrupInfo.DrugName,tbDrupInfo.DrugIsOtc,");
            SQL.AppendLine("  tbDrupInfo.DrugPackSpece,tbDrupInfo.OpenDoseName,tbDrupInfo.DrugState,tbDrupInfo.ProductId,");
            SQL.AppendLine("  tbDrupInfo.DrugApprovalNo,tbDrupInfo.DrugBarCode,tbDrupInfo.DrugPresPrice,tbDrupInfo.DrugPurchasePrice,tbDrugInventory.DrugInvPresPrice FROM tbDrupInfo inner join tbDrugInventory on tbDrupInfo.DrugId=tbDrugInventory.DrugId ");
            return SqlDBhelper.GetList<ZX.HIS.Model.DrupInfo>(SQL.ToString());
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ZX.HIS.Model.DrupInfo DataRowToModel(DataRow row)
        {
            ZX.HIS.Model.DrupInfo model = new ZX.HIS.Model.DrupInfo();
            if (row != null)
            {
                if (row["DrugId"] != null && row["DrugId"].ToString() != "")
                {
                    model.DrugId = int.Parse(row["DrugId"].ToString());
                }
                if (row["HospitalId"] != null && row["HospitalId"].ToString() != "")
                {
                    model.HospitalId = int.Parse(row["HospitalId"].ToString());
                }
                if (row["DrugTypeId"] != null && row["DrugTypeId"].ToString() != "")
                {
                    model.DrugTypeId = row["DrugTypeId"].ToString();
                }
                if (row["DrugName"] != null)
                {
                    model.DrugName = row["DrugName"].ToString();
                }
                if (row["DrugIsOtc"] != null && row["DrugIsOtc"].ToString() != "")
                {
                    model.DrugIsOtc = int.Parse(row["DrugIsOtc"].ToString());
                }
                if (row["DrugPackSpece"] != null)
                {
                    model.DrugPackSpece = row["DrugPackSpece"].ToString();
                }
                if (row["OpenDoseName"] != null && row["OpenDoseName"].ToString() != "")
                {
                    model.OpenDoseName = row["OpenDoseName"].ToString();
                }
                if (row["DrugState"] != null && row["DrugState"].ToString() != "")
                {
                    model.DrugState = int.Parse(row["DrugState"].ToString());
                }
                if (row["ProductId"] != null && row["ProductId"].ToString() != "")
                {
                    model.ProductId = int.Parse(row["ProductId"].ToString());
                }
                if (row["DrugApprovalNo"] != null)
                {
                    model.DrugApprovalNo = row["DrugApprovalNo"].ToString();
                }
                if (row["DrugBarCode"] != null)
                {
                    model.DrugBarCode = row["DrugBarCode"].ToString();
                }
                if (row["DrugPurchasePrice"] != null)
                {
                    model.DrugPurchasePrice = decimal.Parse(row["DrugPurchasePrice"].ToString());
                }
            }
            return model;
        }

        /// <summary>
        /// 药品信息修改返填 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ZX.HIS.Model.DrupInfo DrupInfoUpdShow(int id)
        {
            StringBuilder SQL = new StringBuilder();
            SQL.AppendLine("");
            SQL.AppendLine("SELECT DrugId, HospitalId,DrugTypeId, D.ProductName,DrugName,DrugIsOtc,DrugPackSpece,OpenDoseName,DrugState,a. ProductId,DrugApprovalNo,DrugBarCode,DrugPurchasePrice ");
            SQL.AppendLine("    FROM tbDrupInfo a LEFT JOIN tbProduct D ON A.ProductId=D.ProductId ");
            SQL.AppendLine("WHERE DrugId=" + id + " ");
            return DataRowToModel(SqlDBhelper.GetDataTable(SQL.ToString()).Rows[0]);
        }

        /// <summary>
        /// 药品信息表修改
        /// </summary>
        /// <param name="mode"></param>
        /// <returns></returns>
        public int DrupInfoUpd(ZX.HIS.Model.DrupInfo mode)
        {
            string ComTex = "Proc_DrupInfoUpt";
            SqlParameter[] paemeter ={
                                         new  SqlParameter("@DrugId",SqlDbType.Int,8){Value=mode.@DrugId},
                                         new  SqlParameter("@HospitalId",SqlDbType.Int,8){Value=mode.HospitalId},
                                         new  SqlParameter("@DrugTypeId",SqlDbType.VarChar,500){Value=mode.DrugTypeId},
                                         new  SqlParameter("@DrugName",SqlDbType.VarChar,500){Value=mode.DrugName},
                                         new  SqlParameter("@DrugIsOtc",SqlDbType.Int,8){Value=mode.DrugIsOtc},
                                         new  SqlParameter("@DrugPackSpece",SqlDbType.VarChar,100){Value=mode.DrugPackSpece},
                                         new  SqlParameter("@OpenDoseName",SqlDbType.VarChar,100){Value=mode.OpenDoseName},
                                         new  SqlParameter("@DrugState",SqlDbType.Int,8){Value=mode.DrugState},
                                         new  SqlParameter("@ProductId",SqlDbType.Int){Value=mode.ProductId},
                                         new  SqlParameter("@DrugApprovalNo",SqlDbType.VarChar,100){Value=mode.DrugApprovalNo},
                                         new  SqlParameter("@DrugBarCode",SqlDbType.VarChar,100){Value=mode.DrugBarCode},
                                         new SqlParameter("@DrugPurchasePrice",SqlDbType.Decimal){Value=mode.DrugPurchasePrice}
                        };
            object obj = SqlDBhelper.RunProcedureNonQuery(ComTex, paemeter);
            if (obj != null)
            {
                return Convert.ToInt32(obj);
            }
            return 0;
        }
        #endregion
        #region  BasicMethod
        ///// <summary>
        ///// 得到最大ID
        ///// </summary>
        //public int GetMaxId()
        //{
        //return DbHelperSQL.GetMaxID("DrugId", "tbDrupInfo"); 
        //}

        ///// <summary>
        ///// 是否存在该记录
        ///// </summary>
        //public bool Exists(int DrugId)
        //{
        //    StringBuilder strSql=new StringBuilder();
        //    strSql.Append("select count(1) from tbDrupInfo");
        //    strSql.Append(" where DrugId=@DrugId");
        //    SqlParameter[] parameters = {
        //            new SqlParameter("@DrugId", SqlDbType.Int,4)
        //    };
        //    parameters[0].Value = DrugId;

        //    return DbHelperSQL.Exists(strSql.ToString(),parameters);
        //}


        ///// <summary>
        ///// 增加一条数据
        ///// </summary>
        //public int Add(ZX.HIS.Model.DrupInfo model)
        //{
        //    StringBuilder strSql=new StringBuilder();
        //    strSql.Append("insert into tbDrupInfo(");
        //    strSql.Append("HospitalId,DrugTypeId,DrugName,DrugIsOtc,DrugPackSpece,OpenDoseName,DrugState,ProductId,DrugApprovalNo,DrugBarCode)");
        //    strSql.Append(" values (");
        //    strSql.Append("@HospitalId,@DrugTypeId,@DrugName,@DrugIsOtc,@DrugPackSpece,@OpenDoseName,@DrugState,@ProductId,@DrugApprovalNo,@DrugBarCode)");
        //    strSql.Append(";select @@IDENTITY");
        //    SqlParameter[] parameters = {
        //            new SqlParameter("@HospitalId", SqlDbType.Int,4),
        //            new SqlParameter("@DrugTypeId", SqlDbType.Int,4),
        //            new SqlParameter("@DrugName", SqlDbType.VarChar,100),
        //            new SqlParameter("@DrugIsOtc", SqlDbType.Int,4),
        //            new SqlParameter("@DrugPackSpece", SqlDbType.VarChar,100),
        //            new SqlParameter("@OpenDoseName", SqlDbType.Int,4),
        //            new SqlParameter("@DrugState", SqlDbType.Int,4),
        //            new SqlParameter("@ProductId", SqlDbType.Int,4),
        //            new SqlParameter("@DrugApprovalNo", SqlDbType.VarChar,100),
        //            new SqlParameter("@DrugBarCode", SqlDbType.VarChar,100)};
        //    parameters[0].Value = model.HospitalId;
        //    parameters[1].Value = model.DrugTypeId;
        //    parameters[2].Value = model.DrugName;
        //    parameters[3].Value = model.DrugIsOtc;
        //    parameters[4].Value = model.DrugPackSpece;
        //    parameters[5].Value = model.OpenDoseName;
        //    parameters[6].Value = model.DrugState;
        //    parameters[7].Value = model.ProductId;
        //    parameters[8].Value = model.DrugApprovalNo;
        //    parameters[9].Value = model.DrugBarCode;

        //    object obj = DbHelperSQL.GetSingle(strSql.ToString(),parameters);
        //    if (obj == null)
        //    {
        //        return 0;
        //    }
        //    else
        //    {
        //        return Convert.ToInt32(obj);
        //    }
        //}
        ///// <summary>
        ///// 更新一条数据
        ///// </summary>
        //public bool Update(ZX.HIS.Model.DrupInfo model)
        //{
        //    StringBuilder strSql=new StringBuilder();
        //    strSql.Append("update tbDrupInfo set ");
        //    strSql.Append("HospitalId=@HospitalId,");
        //    strSql.Append("DrugTypeId=@DrugTypeId,");
        //    strSql.Append("DrugName=@DrugName,");
        //    strSql.Append("DrugIsOtc=@DrugIsOtc,");
        //    strSql.Append("DrugPackSpece=@DrugPackSpece,");
        //    strSql.Append("OpenDoseName=@OpenDoseName,");
        //    strSql.Append("DrugState=@DrugState,");
        //    strSql.Append("ProductId=@ProductId,");
        //    strSql.Append("DrugApprovalNo=@DrugApprovalNo,");
        //    strSql.Append("DrugBarCode=@DrugBarCode");
        //    strSql.Append(" where DrugId=@DrugId");
        //    SqlParameter[] parameters = {
        //            new SqlParameter("@HospitalId", SqlDbType.Int,4),
        //            new SqlParameter("@DrugTypeId", SqlDbType.Int,4),
        //            new SqlParameter("@DrugName", SqlDbType.VarChar,100),
        //            new SqlParameter("@DrugIsOtc", SqlDbType.Int,4),
        //            new SqlParameter("@DrugPackSpece", SqlDbType.VarChar,100),
        //            new SqlParameter("@OpenDoseName", SqlDbType.Int,4),
        //            new SqlParameter("@DrugState", SqlDbType.Int,4),
        //            new SqlParameter("@ProductId", SqlDbType.Int,4),
        //            new SqlParameter("@DrugApprovalNo", SqlDbType.VarChar,100),
        //            new SqlParameter("@DrugBarCode", SqlDbType.VarChar,100),
        //            new SqlParameter("@DrugId", SqlDbType.Int,4)};
        //    parameters[0].Value = model.HospitalId;
        //    parameters[1].Value = model.DrugTypeId;
        //    parameters[2].Value = model.DrugName;
        //    parameters[3].Value = model.DrugIsOtc;
        //    parameters[4].Value = model.DrugPackSpece;
        //    parameters[5].Value = model.OpenDoseName;
        //    parameters[6].Value = model.DrugState;
        //    parameters[7].Value = model.ProductId;
        //    parameters[8].Value = model.DrugApprovalNo;
        //    parameters[9].Value = model.DrugBarCode;
        //    parameters[10].Value = model.DrugId;

        //    int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
        //    if (rows > 0)
        //    {
        //        return true;
        //    }
        //    else
        //    {
        //        return false;
        //    }
        //}

        ///// <summary>
        ///// 删除一条数据
        ///// </summary>
        //public bool Delete(int DrugId)
        //{

        //    StringBuilder strSql=new StringBuilder();
        //    strSql.Append("delete from tbDrupInfo ");
        //    strSql.Append(" where DrugId=@DrugId");
        //    SqlParameter[] parameters = {
        //            new SqlParameter("@DrugId", SqlDbType.Int,4)
        //    };
        //    parameters[0].Value = DrugId;

        //    int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
        //    if (rows > 0)
        //    {
        //        return true;
        //    }
        //    else
        //    {
        //        return false;
        //    }
        //}
        ///// <summary>
        ///// 批量删除数据
        ///// </summary>
        //public bool DeleteList(string DrugIdlist )
        //{
        //    StringBuilder strSql=new StringBuilder();
        //    strSql.Append("delete from tbDrupInfo ");
        //    strSql.Append(" where DrugId in ("+DrugIdlist + ")  ");
        //    int rows=DbHelperSQL.ExecuteSql(strSql.ToString());
        //    if (rows > 0)
        //    {
        //        return true;
        //    }
        //    else
        //    {
        //        return false;
        //    }
        //}


        ///// <summary>
        ///// 得到一个对象实体
        ///// </summary>
        //public ZX.HIS.Model.DrupInfo GetModel(int DrugId)
        //{

        //    StringBuilder strSql=new StringBuilder();
        //    strSql.Append("select  top 1 DrugId,HospitalId,DrugTypeId,DrugName,DrugIsOtc,DrugPackSpece,OpenDoseName,DrugState,ProductId,DrugApprovalNo,DrugBarCode from tbDrupInfo ");
        //    strSql.Append(" where DrugId=@DrugId");
        //    SqlParameter[] parameters = {
        //            new SqlParameter("@DrugId", SqlDbType.Int,4)
        //    };
        //    parameters[0].Value = DrugId;

        //    ZX.HIS.Model.DrupInfo model=new ZX.HIS.Model.DrupInfo();
        //    DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
        //    if(ds.Tables[0].Rows.Count>0)
        //    {
        //        return DataRowToModel(ds.Tables[0].Rows[0]);
        //    }
        //    else
        //    {
        //        return null;
        //    }
        //}


        ///// <summary>
        ///// 得到一个对象实体
        ///// </summary>
        //public ZX.HIS.Model.DrupInfo DataRowToModel(DataRow row)
        //{
        //    ZX.HIS.Model.DrupInfo model=new ZX.HIS.Model.DrupInfo();
        //    if (row != null)
        //    {
        //        if(row["DrugId"]!=null && row["DrugId"].ToString()!="")
        //        {
        //            model.DrugId=int.Parse(row["DrugId"].ToString());
        //        }
        //        if(row["HospitalId"]!=null && row["HospitalId"].ToString()!="")
        //        {
        //            model.HospitalId=int.Parse(row["HospitalId"].ToString());
        //        }
        //        if(row["DrugTypeId"]!=null && row["DrugTypeId"].ToString()!="")
        //        {
        //            model.DrugTypeId=int.Parse(row["DrugTypeId"].ToString());
        //        }
        //        if(row["DrugName"]!=null)
        //        {
        //            model.DrugName=row["DrugName"].ToString();
        //        }
        //        if(row["DrugIsOtc"]!=null && row["DrugIsOtc"].ToString()!="")
        //        {
        //            model.DrugIsOtc=int.Parse(row["DrugIsOtc"].ToString());
        //        }
        //        if(row["DrugPackSpece"]!=null)
        //        {
        //            model.DrugPackSpece=row["DrugPackSpece"].ToString();
        //        }
        //        if(row["OpenDoseName"]!=null && row["OpenDoseName"].ToString()!="")
        //        {
        //            model.OpenDoseName=int.Parse(row["OpenDoseName"].ToString());
        //        }
        //        if(row["DrugState"]!=null && row["DrugState"].ToString()!="")
        //        {
        //            model.DrugState=int.Parse(row["DrugState"].ToString());
        //        }
        //        if(row["ProductId"]!=null && row["ProductId"].ToString()!="")
        //        {
        //            model.ProductId=int.Parse(row["ProductId"].ToString());
        //        }
        //        if(row["DrugApprovalNo"]!=null)
        //        {
        //            model.DrugApprovalNo=row["DrugApprovalNo"].ToString();
        //        }
        //        if(row["DrugBarCode"]!=null)
        //        {
        //            model.DrugBarCode=row["DrugBarCode"].ToString();
        //        }
        //    }
        //    return model;
        //}

        ///// <summary>
        ///// 获得数据列表
        ///// </summary>
        //public DataSet GetList(string strWhere)
        //{
        //    StringBuilder strSql=new StringBuilder();
        //    strSql.Append("select DrugId,HospitalId,DrugTypeId,DrugName,DrugIsOtc,DrugPackSpece,OpenDoseName,DrugState,ProductId,DrugApprovalNo,DrugBarCode ");
        //    strSql.Append(" FROM tbDrupInfo ");
        //    if(strWhere.Trim()!="")
        //    {
        //        strSql.Append(" where "+strWhere);
        //    }
        //    return DbHelperSQL.Query(strSql.ToString());
        //}

        ///// <summary>
        ///// 获得前几行数据
        ///// </summary>
        //public DataSet GetList(int Top,string strWhere,string filedOrder)
        //{
        //    StringBuilder strSql=new StringBuilder();
        //    strSql.Append("select ");
        //    if(Top>0)
        //    {
        //        strSql.Append(" top "+Top.ToString());
        //    }
        //    strSql.Append(" DrugId,HospitalId,DrugTypeId,DrugName,DrugIsOtc,DrugPackSpece,OpenDoseName,DrugState,ProductId,DrugApprovalNo,DrugBarCode ");
        //    strSql.Append(" FROM tbDrupInfo ");
        //    if(strWhere.Trim()!="")
        //    {
        //        strSql.Append(" where "+strWhere);
        //    }
        //    strSql.Append(" order by " + filedOrder);
        //    return DbHelperSQL.Query(strSql.ToString());
        //}

        ///// <summary>
        ///// 获取记录总数
        ///// </summary>
        //public int GetRecordCount(string strWhere)
        //{
        //    StringBuilder strSql=new StringBuilder();
        //    strSql.Append("select count(1) FROM tbDrupInfo ");
        //    if(strWhere.Trim()!="")
        //    {
        //        strSql.Append(" where "+strWhere);
        //    }
        //    object obj = DbHelperSQL.GetSingle(strSql.ToString());
        //    if (obj == null)
        //    {
        //        return 0;
        //    }
        //    else
        //    {
        //        return Convert.ToInt32(obj);
        //    }
        //}
        ///// <summary>
        ///// 分页获取数据列表
        ///// </summary>
        //public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        //{
        //    StringBuilder strSql=new StringBuilder();
        //    strSql.Append("SELECT * FROM ( ");
        //    strSql.Append(" SELECT ROW_NUMBER() OVER (");
        //    if (!string.IsNullOrEmpty(orderby.Trim()))
        //    {
        //        strSql.Append("order by T." + orderby );
        //    }
        //    else
        //    {
        //        strSql.Append("order by T.DrugId desc");
        //    }
        //    strSql.Append(")AS Row, T.*  from tbDrupInfo T ");
        //    if (!string.IsNullOrEmpty(strWhere.Trim()))
        //    {
        //        strSql.Append(" WHERE " + strWhere);
        //    }
        //    strSql.Append(" ) TT");
        //    strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
        //    return DbHelperSQL.Query(strSql.ToString());
        //}

        ///*
        ///// <summary>
        ///// 分页获取数据列表
        ///// </summary>
        //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        //{
        //    SqlParameter[] parameters = {
        //            new SqlParameter("@tblName", SqlDbType.VarChar, 255),
        //            new SqlParameter("@fldName", SqlDbType.VarChar, 255),
        //            new SqlParameter("@PageSize", SqlDbType.Int),
        //            new SqlParameter("@PageIndex", SqlDbType.Int),
        //            new SqlParameter("@IsReCount", SqlDbType.Bit),
        //            new SqlParameter("@OrderType", SqlDbType.Bit),
        //            new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
        //            };
        //    parameters[0].Value = "tbDrupInfo";
        //    parameters[1].Value = "DrugId";
        //    parameters[2].Value = PageSize;
        //    parameters[3].Value = PageIndex;
        //    parameters[4].Value = 0;
        //    parameters[5].Value = 0;
        //    parameters[6].Value = strWhere;	
        //    return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
        //}*/

        #endregion  BasicMethod
        #region  ExtensionMethod

        #endregion  ExtensionMethod
    }
}

